package cn.techfan.customerserviceconsole;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

@Component
public class CustomHealthCheck implements HealthIndicator {

    int errorCode = 0;

    @Override
    public Health health() {
        System.out.println("CustomHealthCheck with ErrorCode value：" + errorCode);
        if (errorCode > 4 && errorCode % 6 < 3) {
            errorCode++;
            return Health.down().withDetail("CustomHealth Code", errorCode).build();
        }
        errorCode++;
        return Health.up().build();
    }
}
